/*******************************************************************************
 * Venice Noise Android Application
 * Copyright (C) 2011  Worcester Polytechnic Institute, Wesley Ripley
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * If you plan to use or modify any of this code please contact Fabio Carrera (carrera.fabio@gmail.com).
 * Also please attribute any code used in the final product to the developers. 
 * 
 * Author: Wesley Ripley (wripley@wpi.edu) 
 *******************************************************************************/
package org.venicenoise.app;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

/**
 * The activity that displays the preferences for this application
 * @author Wesley Ripley
 * @version 12/15/2011
 */
public class PreferencesActivity extends PreferenceActivity {
	
	/** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //load preferences from XML
            addPreferencesFromResource(R.xml.preferences);
            
            Preference fieldTestPref = findPreference(getString(R.string.pref_fieldTestingKey));
            if(!AppUtil.FIELD_TESTING_OPTION)
            {
            	//make sure field test mode is off
            	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
            	SharedPreferences.Editor prefEditor = prefs.edit();
            	prefEditor.putBoolean(fieldTestPref.getKey(), false);
            	prefEditor.commit();
            	//remove it from preference screen
            	fieldTestPref.setEnabled(false);
            }
	}

}
